home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / CDTools / S / QuickSearch.awebrx < prev    next >
Text File  |  2000-11-08  |  3KB  |  79 lines

  1. /*
  2.     QuickSearch - Searches the index of the current CD
  3.     $VER: QuickSearch.awebrx 1.3 (8.11.2000)
  4.     (c) Neil Bothwick, Wirenet
  5.  
  6.     1.3  - Uses "parse source" to get the name of the CD
  7. */
  8.  
  9. /* ;;; Initialise */
  10. options results
  11. parse source . ' ' . ' ' . ' ' ScriptName ' ' .
  12. CDName = left(ScriptName, pos(':', ScriptName) - 1)
  13. IndexFile = CDName':CDTools/indices/'CDName
  14. TempFile = 'T:QuickSearch.temp'
  15. ResultFile = 'T:QuickSearch.html'
  16. if ~show('L','rexxsupport.library') then call addlib('rexxsupport.library',0,-30,0)
  17. if ~show('L','rexxdossupport.library') then call addlib('rexxdossupport.library',0,-30,0)
  18.  
  19. AWebPort = address()
  20. if ~abbrev(AWebPort,'AWEB.') then do
  21.     do i = 1 to 25
  22.         if show('P','AWEB.'i) then do
  23.             AWebPort = 'AWEB.'i
  24.             leave
  25.             end
  26.         end
  27.     if ~abbrev(AWebPort,'AWEB.') then exit
  28.     address(AWebPort)
  29.     end
  30. 'get url target=main'
  31. OldPage = result
  32. 'open file://localhost/'CDName':html/Searching.html target main reload'
  33. ;;;     
  34. /* ;;; Search index file */
  35. parse arg SearchStr
  36. if abbrev(SearchStr,'SearchStr="') then parse var SearchStr . '="' SearchStr '"'
  37. SearchStr = translate(SearchStr,' ','+')
  38. address command CDName':System/C/FlashFind >'TempFile IndexFile '"'SearchStr'" NOPREFS QUIET NH'
  39. if RC > 0 then Found = 'NO'
  40. ;;;     
  41. /* ;;; Open output file and write headers */
  42. call open(out,ResultFile,'W')
  43. call writeln(out,'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">')
  44. call writeln(out,'<html><head><title>Search results</title></head><body bgcolor=white>')
  45. call writeln(out,'<p><h4 align="center"><a href="'OldPage'">Return to previous page</a></h4><p>')
  46. call writeln(out,'<h3 align=center>Result of searching for "<font color=red>'SearchStr'</font>"</h3>')
  47. ;;;
  48. /* ;;; Process result into HTML */
  49. if Found = 'NO' then do
  50.     call writeln(out,'<h3 align=center>No matches found for "<font color=red>'SearchStr'</font>" on this CD</h3>')
  51.     call writeln(out,'<p><h4 align="center">Would you like to <a href="file://localhost/'CDName':html/SearchCDs.html">Search other CDs</a> or</h4><p>')
  52.     end
  53. else do
  54.     call open(in,TempFile,'R')
  55.     call writeln(out,'<table width="100%">')
  56.     do until eof(in)
  57.         line = readln(in)
  58.         if line = '' then iterate
  59.         parse var line name =34 path
  60.         name = strip(name)
  61.         line = '<tr><td>'name'<td><a href="x-aweb:rexx/'left(path,pos(':',path))'CDTools/S/AAShowDir 'PathPart(path)'">'path'</a>'
  62.         call writeln(out,line)
  63.         end
  64.     call writeln(out,'</table>')
  65.     end
  66. call writeln(out,'<p><h4 align="center"><a href="'OldPage'">Return to previous page</a></h4><p>')
  67. call writeln(out,'</body></html>')
  68. ;;;  
  69. /* ;;; Close files and load into AWeb */
  70. call close(in)
  71. call close(out)
  72. address command 'delete >NIL:' TempFile
  73. 'open file://localhost/'ResultFile' target main reload'
  74. 'wait file://localhost/'ResultFile
  75. address command 'delete >NIL:' ResultFile
  76. ;;;
  77. exit
  78.  
  79.